package com.eslserver.servletapi.core;

import java.util.Locale;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.eslserver.servletapi.timer.STiTEQCommandTimerInitializer;

@SuppressWarnings("serial")
public class ESLServletAPICore extends HttpServlet {
	public static final Logger LOG = LoggerFactory
			.getLogger(ESLServletAPICore.class);

	public static final String DEFAULT_CONF_FILE = "WEB-INF/eslservletapiconfig.xml";

	private static ESLServletAPIConfig eslServletAPIConfig;

	@Override
	public void init(ServletConfig config) throws ServletException {
		// set locale to EN
		Locale.setDefault(Locale.ENGLISH);

		eslServletAPIConfig = ESLServletAPIConfig.getInstance(config
				.getServletContext().getResourceAsStream(DEFAULT_CONF_FILE));

		STiTEQCommandTimerInitializer.initTasksTimer();

		LOG.info("ESLServletAPI Core Loaded Successfully!");
	}

	public static Config getESLServletAPIConfig() {
		return eslServletAPIConfig;
	}
}
